Create (and use if no -StylesheetURL is given) a default stylesheet, by copying an existing resource.

This commit is contained in:
rfm 2024-09-03 09:11:23 +01:00
parent 2c8528d973
commit db0d5a15e7
5 changed files with 41 additions and 25 deletions

View file

@ -1290,17 +1290,13 @@ static NSMutableSet *textNodes = nil;
[self decIndent];
[buf appendString: @"</title>\n"];
/** handcrafted styles for previous in-line styles */
[buf appendString: indent];
[buf appendString: @"<style type=\"text/css\">\n"];
[buf appendString: indent];
[buf appendString: @"hr.method-separator { width:25%; margin-left:0; }\n"];
[buf appendString: indent];
[buf appendString: @"</style>\n"];
[buf appendString: @"<meta http-equiv=\"Content-Style-Type\""
@" content=\"text/css\"/>\n"];
[buf appendFormat: @"<link rel=\"stylesheet\" type=\"text/css\""
@" href=\"%@\" media=\"screen\" title=\"Normal\" />\n",
[[NSUserDefaults standardUserDefaults] stringForKey:
@"StylesheetURL"]];
#if 0
/** Css : TODO print.css **/
[buf appendString:@"<meta http-equiv=\"Content-Style-Type\" content=\"text/css\"/>\n"];
[buf appendString:@"<link rel=\"stylesheet\" type=\"text/css\" href=\"screen.css\" media=\"screen\" title=\"Normal\" />\n"];
/** Robots **/
[buf appendString:@"<meta name=\"robots\" content=\"all\" />\n"];
#endif

View file

@ -24,6 +24,7 @@
#import "Foundation/NSArray.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSBundle.h"
#import "Foundation/NSCharacterSet.h"
#import "Foundation/NSData.h"
#import "Foundation/NSDictionary.h"
@ -301,6 +302,7 @@ static BOOL snuggleStart(NSString *t)
*/
- (NSArray*) output: (NSMutableDictionary*)d
{
NSFileManager *mgr = [NSFileManager defaultManager];
NSMutableString *str = [NSMutableString stringWithCapacity: 10240];
NSDictionary *classes;
NSDictionary *categories;
@ -312,6 +314,7 @@ static BOOL snuggleStart(NSString *t)
NSDictionary *macros;
NSMutableArray *files;
NSArray *authors;
NSString *style = @"default-styles.css";
NSString *base;
NSString *tmp;
NSString *file;
@ -328,9 +331,25 @@ static BOOL snuggleStart(NSString *t)
file = [file stringByAppendingPathExtension: @"gsdoc"];
}
dest = [info objectForKey: @"directory"];
if ([dest length] > 0 && [file isAbsolutePath] == NO)
if ([dest length] > 0)
{
file = [dest stringByAppendingPathComponent: file];
style = [dest stringByAppendingPathComponent: style];
if ([file isAbsolutePath] == NO)
{
file = [dest stringByAppendingPathComponent: file];
}
}
/* When there is no local default stylesheet present, we copy the
* stylesheet from the main bundle.
*/
if ([mgr isReadableFileAtPath: style] == NO)
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *path;
path = [bundle pathForResource: @"default-styles" ofType: @"css"];
[mgr copyPath: path toPath: style handler: nil];
}
classes = [info objectForKey: @"Classes"];
@ -361,12 +380,9 @@ static BOOL snuggleStart(NSString *t)
tmp = [[NSUserDefaults standardUserDefaults]
stringForKey: @"StylesheetURL"];
}
if (tmp)
{
[str appendString: @" stylesheeturl=\""];
[str appendString: tmp];
[str appendString: @"\""];
}
[str appendString: @" stylesheeturl=\""];
[str appendString: tmp];
[str appendString: @"\""];
tmp = [info objectForKey: @"up"];
if (tmp != nil)
@ -2370,12 +2386,10 @@ static BOOL snuggleStart(NSString *t)
tmp = [[NSUserDefaults standardUserDefaults]
stringForKey: @"StylesheetURL"];
}
if (tmp)
{
[str appendString: @" stylesheeturl=\""];
[str appendString: tmp];
[str appendString: @"\""];
}
[str appendString: @" stylesheeturl=\""];
[str appendString: tmp];
[str appendString: @"\""];
/*
* If a -Up default has been set, create an up link in this
* template file... as long as the specified up link is not

View file

@ -117,6 +117,10 @@ ifneq ($(HAVE_DOT), )
AGSHtml.m_FILE_FLAGS+= -DHAVE_DOT=$(HAVE_DOT)
endif
autogsdoc_HAS_RESOURCE_BUNDLE = yes
autogsdoc_RESOURCE_FILES = \
default-styles.css
# Reset this variable (defined in config.mak) to avoid useless linkage
# against the libraries gnustep-base uses.
CONFIG_SYSTEM_LIBS :=

View file

@ -464,7 +464,8 @@
</item>
<item><strong>StylesheetURL</strong>
The URL of a CSS document to be used as the stadard stylesheet for
generated autogsdoc files.
generated autogsdoc files. If this is not specified the default of
a local document default-styles.css is used.
</item>
<item><strong>SystemProjects</strong>
This value is used to control the automatic inclusion of system
@ -751,6 +752,7 @@ main(int argc, char **argv, char **env)
defs = [NSUserDefaults standardUserDefaults];
[defs registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
@"Untitled", @"Project",
@"default-styles.css", @"StylesheetURL",
nil]];
// BEGIN test for any unrecognized arguments, or "--help"

0
Tools/default-styles.css Normal file
View file