Permalink
Browse files

Custom CSS support (experimental)

git-svn-id: http://readown.googlecode.com/svn/trunk@11 6adf6fe4-e8f3-11dd-9059-71fac19e68c6
  • Loading branch information...
suminb@gmail.com
suminb@gmail.com committed Jul 18, 2010
1 parent 222de50 commit 97cc459e3f5bff938ef958c8142fc735b89465df

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Binary file not shown.
View
@@ -97,7 +97,7 @@ - (id)init
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
-
+
}
return self;
}
@@ -145,9 +145,23 @@ - (void)awakeFromNib
- (void)loadFromBaseURL {
text = [NSString stringWithContentsOfURL:baseURL encoding:NSUTF8StringEncoding error:nil];
- NSString *html = [NSString stringWithFormat:@"<html><body>%@</body></html>", [text stringWithMarkdownAndSmartyPants]];
+ NSString *html = nil;
+
+ NSString *filename = [[baseURL path] stringByDeletingPathExtension];
- //NSLog(@"%@", html);
+ // look for CSS file that has the same file name
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSString *cssPath = [filename stringByAppendingString:@".css"];
+ if([fileManager fileExistsAtPath:cssPath]) {
+ // TODO: need exception handlings
+ NSString *css = [NSString stringWithContentsOfFile:cssPath];
+
+ // TODO:
+ html = [NSString stringWithFormat:@"<html><head><style>%@</style></head><body>%@</body></html>", css, [text stringWithMarkdownAndSmartyPants]];
+ }
+ else {
+ html = [NSString stringWithFormat:@"<html><body>%@</body></html>", [text stringWithMarkdownAndSmartyPants]];
+ }
[[webView mainFrame] loadHTMLString:html baseURL:baseURL];
}

0 comments on commit 97cc459

Please sign in to comment.