* GSWeb.framework/GSWeb.h (GSWImageInfo): Foward declare.

* GSWeb.framework/GSWHTMLDynamicElement.h/m
	(-/+[_frameworkNameForAssociation:inComponent:]): Convert to class
	method.  Cleanup implementation.
	* GSWeb.framework/GSWImage.m
	(+[_appendFilenameToResponse:inContext:framework:filename:width:height:]):
	Add handling for image url and cleanup implementation.
	(-[_appendFilenameToResponse:inContext:]): Delegate to class method.
	* GSWeb.framework/GSWResourceManager.h/m
	(-[_imageInfoForUrl:fileName:framework:languages:]): New method.
	(-[errorMessageUrlForResourceNamed:inFramework:]): Reformat.
	(-[_cacheData:]): Ditto.

	* Examples/WebBookStore1/BookStore.eomodeld/index.eomodeld:
	Update adaptor name.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@28182 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2009-04-06 22:22:14 +00:00
parent 8248a705a0
commit b6bbd5b0cb
8 changed files with 216 additions and 219 deletions

View file

@ -1,3 +1,21 @@
2009-04-07 David Ayers <ayers@fsfe.org>
* GSWeb.framework/GSWeb.h (GSWImageInfo): Foward declare.
* GSWeb.framework/GSWHTMLDynamicElement.h/m
(-/+[_frameworkNameForAssociation:inComponent:]): Convert to class
method. Cleanup implementation.
* GSWeb.framework/GSWImage.m
(+[_appendFilenameToResponse:inContext:framework:filename:width:height:]):
Add handling for image url and cleanup implementation.
(-[_appendFilenameToResponse:inContext:]): Delegate to class method.
* GSWeb.framework/GSWResourceManager.h/m
(-[_imageInfoForUrl:fileName:framework:languages:]): New method.
(-[errorMessageUrlForResourceNamed:inFramework:]): Reformat.
(-[_cacheData:]): Ditto.
* Examples/WebBookStore1/BookStore.eomodeld/index.eomodeld:
Update adaptor name.
2009-04-05 David Ayers <ayers@fsfe.org>
* GSWeb.framework/GSWImageInfo.h/m: New files.

View file

@ -1,6 +1,6 @@
{
EOModelVersion = 2;
adaptorName = Postgres95;
adaptorName = PostgreSQL;
connectionDictionary = {
databaseName = BookStore;
};

View file

@ -48,6 +48,9 @@
GSWAssociation * _secure;
}
+ (NSString*) _frameworkNameForAssociation: (GSWAssociation*)association
inComponent: (GSWComponent *) component;
- (NSDictionary*) computeQueryDictionaryWithActionClassAssociation: (GSWAssociation*)actionClass
directActionNameAssociation: (GSWAssociation*)directActionName
queryDictionaryAssociation: (GSWAssociation*)queryDictionary
@ -83,8 +86,6 @@
- (NSString*) constantAttributesRepresentation;
- (NSString*) _frameworkNameForAssociation: (GSWAssociation*)association
inComponent: (GSWComponent *) component;
- (NSString*) elementName;
- (BOOL) secureInContext:(GSWContext*) context;

View file

@ -309,39 +309,41 @@ static inline BOOL _needQuote(NSString* str_needQuote)
}
// _frameworkNameInComponent
- (NSString*) _frameworkNameForAssociation: (GSWAssociation*)association
+ (NSString*) _frameworkNameForAssociation: (GSWAssociation*)association
inComponent: (GSWComponent *) component
{
NSString * s = nil;
NSString *name = nil;
if (association != nil) {
s = [association valueInComponent:component];
if (s != nil) {
if ([[s lowercaseString] isEqual:@"app"]) {
s = nil;
}
} else {
if (association != nil)
{
name = [association valueInComponent:component];
if (name)
{
if ([@"app" caseInsensativeCompare: name])
{
name = nil;
}
}
else
{
if (component != nil)
{
name = [component frameworkName];
}
[GSWApp debugWithFormat:@"%s evaluated to nil. Defaulting to %@",
__PRETTY_FUNCTION__,
(name ? name : @"app")];
}
}
else
{
if (component != nil)
{
s = [component frameworkName];
}
NSString * tmpStr;
if ((s != nil)) {
tmpStr = s;
} else {
tmpStr = @"app";
}
[GSWApp debugWithFormat:@"%s evaluated to nil. Defaulting to %@",
__PRETTY_FUNCTION__,
tmpStr];
{
name = [component frameworkName];
}
}
} else {
if (component != nil) {
s = [component frameworkName];
}
}
return s;
return name;
}
// computeActionStringInContext in wo5

View file

@ -94,10 +94,10 @@ RCS_ID("$Id$")
};
// GSWImage._appendFilenameToResponseInContext(woresponse, wocontext, _framework, _filename, _width, _height);
/* This class method does not actually exist in WO45 yet it seems subsequent
* versions implement it to factor out code replicated by mutliple classes
* across the class hierarchy.
*/
+ (void) _appendFilenameToResponse:(GSWResponse *) response
inContext:(GSWContext *) context
framework:(GSWAssociation*) framework
@ -105,89 +105,114 @@ RCS_ID("$Id$")
width:(GSWAssociation*) width
height:(GSWAssociation*) height
{
id widthValue = nil;
id heightValue = nil;
BOOL hasNoWidth = NO;
BOOL hasNoHeight = NO;
NSString * frameworkName;
GSWResourceManager *resourcemanager;
GSWComponent *component;
NSString *fileNameValue;
NSString *frameworkName = nil;
NSString *resourceURL;
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
resourcemanager = [GSWApp resourceManager];
component = GSWContext_component(context);
fileNameValue = [filename valueInComponent:component];
frameworkName
= [GSWHTMLDynamicElement _frameworkNameForAssociation: framework
inComponent: component];
GSWComponent * component = GSWContext_component(context);
NSString* fileNameValue = [filename valueInComponent:component];
resourceURL = [context _urlForResourceNamed: fileNameValue
inFramework: frameworkName];
// i think we have to use component, because we are in a '+' method here. dw
frameworkName = [(GSWHTMLDynamicElement*) component _frameworkNameForAssociation: framework
inComponent: component];
if (resourceURL != nil)
{
NSString *widthStr = nil;
NSString *heightStr = nil;
BOOL calculateWidth = NO;
BOOL calculateHeight = NO;
NSString * resourceURL = [context _urlForResourceNamed:frameworkName inFramework: frameworkName];
if (width != nil || height != nil)
{
if (width != nil)
{
id widthValue;
widthValue = [width valueInComponent:component];
if (widthValue)
{
widthStr = NSStringWithObject(widthValue);
}
calculateWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
}
if (height != nil)
{
id heightValue;
heightValue = [height valueInComponent:component];
if (heightValue)
{
heightStr = NSStringWithObject(heightValue);
}
calculateHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
}
}
else
{
calculateWidth = YES;
calculateHeight = YES;
if (resourceURL != nil) {
NSString * widthStr = nil;
NSString * heightStr = nil;
if (width != nil || height != nil) {
if (width != nil) {
widthValue = [width valueInComponent:component];
widthStr = widthValue != nil ? widthValue : nil; // stringValue?
hasNoWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
}
if (height != nil) {
heightValue = [height valueInComponent:component];
heightStr = heightValue != nil ? heightValue : nil; // stringValue?
hasNoHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
}
} else {
hasNoWidth = YES;
hasNoHeight = YES;
// do we really need that log? dw.
// NSLog("%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.", [self class], fileNameValue);
GSOnceMLog(@"%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.",
NSStringFromClass([self class]), fileNameValue);
}
if (calculateWidth || calculateHeight)
{
GSWImageInfo * imageinfo;
imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
fileName: fileNameValue
framework: frameworkName
languages: [context languages]];
if (imageinfo != nil)
{
if (calculateWidth)
{
widthStr = [imageinfo widthString];
}
if (calculateHeight)
{
heightStr = [imageinfo heightString];
}
}
else
{
NSLog(@"%@: Could not get height/width information for image at '%@' '%@' '%@'",
NSStringFromClass([self class]), resourceURL,
fileNameValue, frameworkName);
}
}
[response _appendTagAttribute: @"src"
value: resourceURL
escapingHTMLAttributeValue: NO];
if (widthStr != nil)
{
[response _appendTagAttribute: @"width"
value: widthStr
escapingHTMLAttributeValue: NO];
}
if (heightStr != nil)
{
[response _appendTagAttribute: @"height"
value: heightStr
escapingHTMLAttributeValue: NO];
}
}
// GSWeb does not have that jet.
//
// if (hasNoWidth || hasNoHeight) {
// GSWImageInfo * imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
// fileName: fileNameValue
// framework: frameworkName
// languages: [context _languages]]);
// if (imageinfo != nil) {
// if (hasNoWidth)
// {
// widthStr = imageinfo.widthString();
// }
// if (hasNoHeight)
// {
// heightStr = imageinfo.heightString();
// }
// } else
// {
// NSLog("%@: could not get height/width information for image at '%@/%@/%@'",
// [self class], resourceURL, fileNameValue, frameworkName);
// }
// }
[response _appendTagAttribute: @"src"
value: resourceURL
escapingHTMLAttributeValue: NO];
if (widthStr != nil) {
[response _appendTagAttribute: @"width"
value: widthStr
escapingHTMLAttributeValue: NO];
else
{
NSString *message
= [resourcemanager errorMessageUrlForResourceNamed: fileNameValue
inFramework: frameworkName];
[response _appendTagAttribute:@"src"
value: message
escapingHTMLAttributeValue:NO];
}
if (heightStr != nil) {
[response _appendTagAttribute: @"height"
value: heightStr
escapingHTMLAttributeValue: NO];
}
} else {
[response _appendTagAttribute:@"src"
value:[resourcemanager errorMessageUrlForResourceNamed: fileNameValue
inFramework: frameworkName]
escapingHTMLAttributeValue:NO];
}
}
// used from GSWActiveImage
@ -221,102 +246,21 @@ RCS_ID("$Id$")
}
}
/* This function exists in WO45 and its implementation coresponds
* to the class method. Yet insubesquent versions of WO it has
* been consolidated into the class method. We keep this method
* to remain compatible yet internally take advantage of the class method
* where applicable.
*/
- (void) _appendFilenameToResponse:(GSWResponse *) response
inContext:(GSWContext *) context
{
id widthValue = nil;
id heightValue = nil;
BOOL hasNoWidth = NO;
BOOL hasNoHeight = NO;
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
GSWComponent * component = GSWContext_component(context);
NSString* fileNameValue = [_filename valueInComponent:component];
NSString * frameworkName = [self _frameworkNameForAssociation: _framework
inComponent: component];
NSString * resourceURL = [context _urlForResourceNamed:frameworkName inFramework: frameworkName];
if (resourceURL != nil) {
NSString * widthStr = nil;
NSString * heightStr = nil;
NSLog(@"%s resourceURL:%@",__PRETTY_FUNCTION__, resourceURL);
if (_width != nil || _height != nil) {
if (_width != nil) {
widthValue = [_width valueInComponent:component];
if (widthValue != nil) {
widthStr = NSStringWithObject(widthValue);
}
hasNoWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
}
if (_height != nil) {
heightValue = [_height valueInComponent:component];
if (heightValue != nil) {
heightStr = NSStringWithObject(heightValue);
}
hasNoHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
}
} else {
hasNoWidth = YES;
hasNoHeight = YES;
// do we really need that log? dw.
// NSLog("%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.", [self class], fileNameValue);
}
// GSWeb does not have that jet.
//
// if (hasNoWidth || hasNoHeight) {
// GSWImageInfo * imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
// fileName: fileNameValue
// framework: frameworkName
// languages: [context _languages]]);
// if (imageinfo != nil) {
// if (hasNoWidth)
// {
// widthStr = imageinfo.widthString();
// }
// if (hasNoHeight)
// {
// heightStr = imageinfo.heightString();
// }
// } else
// {
// NSLog("%@: could not get height/width information for image at '%@/%@/%@'",
// [self class], resourceURL, fileNameValue, frameworkName);
// }
// }
[response _appendTagAttribute: @"src"
value: resourceURL
escapingHTMLAttributeValue: NO];
if (widthStr != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
width__Key,
widthStr,
NO);
}
if (heightStr != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
height__Key,
heightStr,
NO);
}
} else { // resourceURL is nil
NSLog(@"%s resourceURL is nil self:%@",__PRETTY_FUNCTION__, self);
[response _appendTagAttribute:@"src"
value:[resourcemanager errorMessageUrlForResourceNamed: fileNameValue
inFramework: frameworkName]
escapingHTMLAttributeValue:NO];
}
[GSWImage _appendFilenameToResponse: response
inContext: context
framework: _framework
filename: _filename
width: _width
height: _height];
}
-(void) _appendCloseTagToResponse:(GSWResponse *) response
@ -325,4 +269,15 @@ RCS_ID("$Id$")
// do nothing!
}
/* This function exists in WO45 and its implementation coresponds
* to the class method of GSWHTMLDynamicElement. Yet insubesquent
* versions of WO it has been consolidated into the class method.
* We keep this method to remain compatible yet internally take
* advantage of the class method where applicable.
*/
- (NSString*) _frameworkNameInComponent: (GSWComponent *) component
{
return [GSWHTMLDynamicElement _frameworkNameForAssociation: _framework
inComponent: component];
}
@end

View file

@ -220,6 +220,10 @@ bundle if none is found
inFramework:(NSString *) frameworkName;
- (void) _cacheData:(GSWURLValuedElementData *) aData;
- (GSWImageInfo *) _imageInfoForUrl:(NSString *)resourceURL
fileName:(NSString *)filename
framework:(NSString *)frameworkName
languages:(NSArray *)languages;
@end

View file

@ -1780,30 +1780,46 @@ bundle if none is found
};
// wo
- (NSString*) errorMessageUrlForResourceNamed:(NSString *) resourceName
inFramework:(NSString *) frameworkName
- (NSString *) errorMessageUrlForResourceNamed:(NSString *) resourceName
inFramework:(NSString *) frameworkName
{
NSString * url = nil;
if( resourceName == nil) {
resourceName = @"nil";
}
if (frameworkName != nil) {
url = [NSString stringWithFormat:@"/ERROR/NOT_FOUND/framework=%@/filename=%@", frameworkName, resourceName];
} else {
NSString * s3 = [GSWApp name];
url = [NSString stringWithFormat:@"/ERROR/NOT_FOUND/app=%@/filename=%@", s3, resourceName];
}
if( resourceName == nil)
{
resourceName = @"nil";
}
if (frameworkName != nil)
{
url = [NSString stringWithFormat:@"/ERROR/NOT_FOUND/framework=%@/filename=%@", frameworkName, resourceName];
}
else
{
NSString * s3 = [GSWApp name];
url = [NSString stringWithFormat:@"/ERROR/NOT_FOUND/app=%@/filename=%@", s3, resourceName];
}
return url;
}
// checkme: locking?? davew
- (void) _cacheData:(GSWURLValuedElementData *) aData
{
if (aData != nil) {
[_urlValuedElementsData setObject: aData
forKey: [aData key]];
}
if (aData != nil)
{
[_urlValuedElementsData setObject: aData
forKey: [aData key]];
}
}
- (GSWImageInfo *) _imageInfoForUrl:(NSString *)resourceURL
fileName:(NSString *)filename
framework:(NSString *)frameworkName
languages:(NSArray *)languages
{
NSString *path = [self pathForResourceNamed:filename
inFramework:(NSString*)frameworkName
languages:(NSArray*)languages];
return [GSWImageInfo imageInfoWithFile: path];
}
@end

View file

@ -149,6 +149,7 @@
@class GSWMonitorXMLDecoder;
@class GSWRecording;
@class GSWInputStreamData;
@class GSWImageInfo;
#include "GSWDefines.h"
#include "GSWConstants.h"